package com.owen.he.jee.vo;

import lombok.Data;
import lombok.EqualsAndHashCode;

import com.owen.he.jee.utils.JsonMapper;

@Data
@EqualsAndHashCode(callSuper=false)
public class ReturnData {
	private boolean success;
	private String message;

	public ReturnData() {}

    public ReturnData(boolean success, String message) {
        this.success = success;
        this.message = message;
    }

	public static ReturnData returnSuccess() {
		return returnSuccess("操作成功");
	}

	public static ReturnData returnSuccess(String message) {
		return new ReturnData(true, message);
	}

	public static ReturnData returnFailure() {
		return returnFailure("操作失败");
	}

	public static ReturnData returnFailure(String message) {
		return new ReturnData(false, message);
	}

	public static String returnSuccessJson() {
		return JsonMapper.getInstance().toJson(returnSuccess("操作成功"));
	}

	public static String returnSuccessJson(String message) {
		return JsonMapper.getInstance().toJson(new ReturnData(true, message));
	}

	public static String returnFailureJson() {
		return JsonMapper.getInstance().toJson(returnSuccess("操作失败"));
	}

    public static String returnFailureJson(String message){
    	return JsonMapper.getInstance().toJson(new ReturnData(false, message));
    }

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}